﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using MyBet.Web;
using System.Linq;

namespace MyBet.Class
{
    public class DaysList
    {
        
        public enum DayStatus { NotStarted, Bet, Finished } ;

        public Dictionary<int, EventServiceReference.EventObject> EventsDictionnary
        {
            get { return App.EventsDictionary; }
            set { App.EventsDictionary = value; }
        }

        public DaysList()
        {
            App.EventsDictionary = new Dictionary<int, EventServiceReference.EventObject>();
        }

        /// <summary>
        /// Return current day to bet or in pending of results
        /// </summary>
        /// <returns></returns>
        public int GetCurrentEventId()
        {
            return EventHelper.GetCurrentEventId(EventsDictionnary);
        }

        public static DayStatus GetStatus(EventServiceReference.EventObject evt)
        {
//#if DEBUG
//            return DayStatus.NotStarted;
//#else
            // case 1 : Finished : Bet is closed
            if (evt._closeDate < DateTime.UtcNow)
            {
                return DayStatus.Finished;
            }
            // case 2 : Bets are opened
            if ((evt._openDate < DateTime.UtcNow) && (evt._closeDate > DateTime.UtcNow))
            {
                return DayStatus.Bet;
            }

            // case 3 : Not started
            return DayStatus.NotStarted;
//#endif
        }

    }
}
